using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using IFramework;
public class TestAstar : MonoBehaviour
{
    static int[,] a;
    void Start()
    {
        a = new int[10, 10]
               {
                   { 1,1,1,1,1,0,1,1,1,1},
                   { 1,1,1,1,1,0,1,1,1,1},
                   { 1,1,1,1,1,1,1,1,1,1},
                   { 1,1,1,1,1,1,1,1,1,1},
                   { 1,1,1,1,1,1,1,1,1,1},
                   { 1,1,1,1,1,1,1,1,1,1},
                   { 1,1,1,1,1,1,1,1,1,1},
                   { 1,1,1,1,1,1,1,1,1,1},
                   { 1,1,1,1,1,1,1,1,1,1},
                   { 1,1,1,1,1,0,1,1,1,1},
               };
        AStarNode2X[,] nodes = new AStarNode2X[10, 10];
        AStarMap2X map = new AStarMap2X(nodes, 10, 10);
        AStarSeacher2X sear = new AStarSeacher2X(map);
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                if (a[i, j] == 1)
                {
                    nodes[i, j] = new AStarNode2X(i, j, AStarNodeType.Walkable);
                    //Console.Write("_ ");
                }
                else
                {
                    nodes[i, j] = new AStarNode2X(i, j, AStarNodeType.Wall);
                    //Console.Write("# ");

                }

            }
            //Log.L();
        }
        try
        {

            AStarNode2X[] result = sear.Search(nodes[0, 0], nodes[9, 9]);

            foreach (var item in result)
            {
                Debug.Log(item.MapPosX + " " + item.MapPosY);
            }

        }
        catch (System.Exception)
        {

            Debug.Log("none");
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
